<?php
    $attribute = pc_variable("attribute");
    $name = pc_variable("name");
    $value = pc_variable("value");
?>
<label for="entity.<?php pc_echo($name); ?>"<?php if($attribute->isRequired()) { ?> class="required"<?php } ?>><?php pc_echo(pc_message("field." . $name)); ?></label>
<input type="file" id="entity.<?php pc_echo($name); ?>" name="entity.<?php pc_echo($name); ?>"/><br/>
<?php 
    if($value !== null) { 
    $image = pc_image($value, 0, 0);
    if($image->getWidth() > 640) {
        $image = pc_image($value, 640, 0);
    }
?>
    <label><?php pc_echo(pc_message("field." . $name . ".example")); ?></label>
    <img width="<?php pc_echo($image->getWidth()); ?>" height="<?php pc_echo($image->getHeight()); ?>" src="<?php pc_echo($image->getContextLocation()); ?>" alt="<?php pc_echo($image->getFile()->getName()); ?>" />
<?php } ?>